lobsterh5.main({
    data: {
        doctId: 0,
        page: 1,
        perPage: 5,
        flag: true,
        loading: false, //状态标记
    },
    pageload() {
        var self = this;
        self.data.doctId = lobsterh5.GetUrlParam('doctId');
        self.getevaluationinfo();
        self.initevent();
    },
    initevent() {
        var self = this;

        //下拉加载数据
        $(document.body).infinite(100).on("infinite", function () {
            if (self.data.loading) return;
            self.data.loading = true;
            setTimeout(function () {
                self.data.page++;
                if (self.data.flag) {
                    self.getevaluationinfo();
                }
                self.data.loading = false;
            }, 1000);
        });
    },
    getevaluationinfo() {
        var self = this;
        $.showLoading();
        lobsterh5.GETAPI('tsevaluation.getevaluationbydoctor', { doctId: self.data.doctId, page: self.data.page, perPage: self.data.perPage }).then(retdata => {
            if (retdata.data && retdata.data.length > 0) {

                if (retdata.data.length < self.data.perPage) {
                    self.data.flag = false;//设置没有数据了标记
                    $(document.body).destroyInfinite();
                    $("#more").html("没有更多数据了");
                }

                //显示评价
                var html = template("tplevaluation", { list: retdata.data });
                $("#evaluationinfo").append(html);

                $.hideLoading();


                //点赞
                $('.btngivecount').click(function () {
                    var id = $(this).data("id");
                    $.showLoading();
                    lobsterh5.GETAPI('tsevaluation.updateevaluationgivecount', { id: id }).then(retdata => {
                        $.hideLoading();
                        $.toast("点赞成功", 'text');
                        $(this).find('.weui-comment-num').html(retdata.givecount);
                    })
                });
            } else {
                $('#evaluationinfo').html('暂无评价');
            }
        }).catch(res => {
            $.toast(res.msg, 'text');
        })
    },
}, false); 